<template>
  <div class="content-wrapper">
    <div class="content-container">
      <el-form :inline="true" :model="listQuery" class="filter-container">
        <el-form-item label="试卷">
          <el-input
            v-model.trim="listQuery.examinationPaperName"
            size="mini"
            placeholder="试卷名称"
          />
        </el-form-item>
        <el-form-item label="部门">
          <el-select v-model="listQuery.examineeUserGroupId" size="mini">
            <el-option
              v-for="item in userGroupOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            class="filter-item"
            size="small"
            round
            type="primary"
            icon="el-icon-search"
            @click="getDataList"
          >
            搜索
          </el-button>
          <!-- <el-button
            class="filter-item"
            size="small"
            round
            icon="el-icon-download"
            @click="handleFilter"
          >
            导出
          </el-button> -->
        </el-form-item>
      </el-form>
      <el-table
        v-loading="listLoading"
        :data="dataList"
        highlight-current-row
        default-expand-all
        row-key="id"
        lazy
      >
        <el-table-column label="培训名称" prop="label" min-width="200px" />
        <el-table-column label="培训时间" prop="startTime" width="160px" />
        <el-table-column
          label="培训方式"
          prop="modeName"
          width="150px"
          align="center"
        />
        <el-table-column label="考核方式" prop="assessName" width="150px" />

        <el-table-column label="创建时间" prop="createTime" width="160px" />
        <el-table-column
          label="操作"
          align="center"
          width="150px"
          fixed="right"
        >
          <template slot-scope="{ row }">
            <el-dropdown trigger="click" class="filter-item">
              <el-button type="text" class="el-icon-more" />
              <el-dropdown-menu slot="dropdown" class="user-dropdown">
                <!--                <el-dropdown-item v-if="row.passFlag == 0" @click.native="viewRecord(row)">批改</el-dropdown-item>-->
                <el-dropdown-item @click.native="viewRecord(row)"
                  >查看</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import {
  listTrainByClassify,
  getExaminationRecord,
  listTrainClassify
} from '@/api/ts/record'

export default {
  components: {},
  data() {
    return {
      dataList: [],
      total: 0,
      paperOptions: [],
      userGroupOptions: [],
      passFlagOptions: [
        { value: 0, label: '未评' },
        { value: 1, label: '合格' },
        { value: 2, label: '不合格' }
      ],
      listQuery: {
        pageIndex: 0,
        pageNumber: 1,
        pageSize: 5,
        examineePaperId: null,
        examineeUserGroupId: null,
        examineeUserName: null,
        passFlag: null
      },
      listLoading: false,
      recordViewDialog: false,
      propsData: null
    }
  },
  mounted() {
    this.getDataList()
  },
  methods: {
    closeDialogVal(val) {
      this.getDataList()
      this.recordViewDialog = val
    },
    viewRecord(row) {

      this.$router.push({
        path: '/train/train_record_detail_page',
        query: { trainId: row.trainId, trainName: row.label }
      })
    },
    getDataList() {
      listTrainByClassify({
        assess: 'assess_examination',
        withExaminationRecord: true
      }).then((res) => {
        this.dataList = res.data
      })
    },
    // 懒加载
    load(tree, treeNode, resolve) {
      setTimeout(() => {
        listTrainByClassify({
          trainClassify: tree.dictCode,
          assess: 'assess_examination'
        }).then((res) => {
          resolve(res.data)
        })
      }, 1000)
    },
    handleFilter() {},
    trainId(row) {
      return row.examinationRecordId
    }
  }
}
</script>
<style>
.view_record .el-dialog .el-dialog__header {
  padding: 0px !important;
}
.view_record .el-dialog .el-dialog__body {
  padding: 30px 0px !important;
}
</style>
